#pragma once
#include <hash_map>
#include <stdexcept>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <firebird/detail/config.hpp>
#include <firebird/message/message.hpp>
#include <firebird/service/service.hpp>
#include <firebird/protocol/protocol.hpp>
namespace firebird {

struct user_status {
	bool				online;
	std::time_t			last_login_time;
	std::time_t			last_operation_time;
	std::pair<int, int> last_operation;
};

typedef std::hash_map<qword, user_status> user_status_map;


class FIREBIRD_DECL monitor_service : public service {
public:
	monitor_service(bus& bus);

	int calc_online(int srv_id = 0, int func_id = 0);

protected:
	virtual void start() {};
	virtual void stop() {};
	virtual void handle_message(message& msg);

private:
	bool active_;
	int session_timeout_;
	user_status_map users_status_;
};

}


